package fr.emn.integration.synthese.controle;
import java.awt.event.ActionEvent;
	import java.awt.event.ActionListener;
	import java.sql.SQLException;

import javax.swing.JOptionPane;

import fr.emn.integration.synthese.abstraction.Cours;
import fr.emn.integration.synthese.abstraction.Evaluation;
import fr.emn.integration.synthese.presentation.EvaluationDialog;
	
public class ControlJButtonSaveEvaluation implements ActionListener {

		private Cours modele;
		private boolean creation;
		private EvaluationDialog parent;

		public ControlJButtonSaveEvaluation(EvaluationDialog parent, Cours modele,
				boolean creation) {
			this.modele = modele;
			this.parent = parent;
			this.creation = creation;
		}

		@Override
		public void actionPerformed(ActionEvent e) {
			if (parent.getNum_Eval()!=-1) {
				Evaluation eval = new Evaluation(parent.getNum_Eval(),modele.getGroupeCourante(), parent.getCorrecteur(), modele.getModuleCourante());
				try {
					modele.saveEvaluation(eval, creation);
					parent.setVisible(false);
				} catch (SQLException e1) {
					JOptionPane.showMessageDialog(parent, "On ne peut pas!", "Erreur!",
							JOptionPane.ERROR_MESSAGE);
					System.out.println(e1);
				}
			}
		}

	}


